<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
         //  行/形参
        function fn(callback){
            callback(999)
        }
        //实参
        fn(function(data){
            console.log(data);
        })
        // 自己封装myforEach 
        var arr=[1,2,33,44,55]
        arr.forEach(function(v,i){
            console.log(v);
            console.log(i);
        })
        var arr=[1,2,33,44,55]
        Array.prototype.myforEach=function(fn){
            console.log(this);
            for(var i=0;i<this.length;i++){
                fn(this[i],i)
            }
        }
        arr.myforEach(function (v, i) {
                console.log(v, i)
        })
         //高阶函数：find() findIndex() map()    forEach()   filter() some() every()
        //      reduce(functon(p,n){})
         var arr2 = [1, 2, 3, 4]
            var s = arr2.reduce(function (p, n) {
                return p += n

            })
            console.log(s);
            
    </script>
</body>
</html>